Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Collapse Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Use BETWEEN instead of IN

 
EMP
ID Name Country Salary
1 Vijay India 6000
2 Bill USA 8000
3 Kris France 3000
---- Low Performance by using IN
SELECT * FROM EMP WHERE ID IN (1,2,3,4,5)
---- High Performance by using BETWEEN
SELECT * FROM EMP WHERE ID BETWEEN 1 AND 5
---- both Queries will give the same output but Performance is different, if the data is tooooo big